home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of a generic pre/post-processor
-
- #include "NSDLL.h"
-
- /***************************/
- /* Activation of component */
- __declspec(dllexport) BOOL performPrePost(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *input, // Pointer to the input data
- NSFloat *output, // Pointer to the output data
- int rows, // Number of rows of data
- int cols, // Number of cols of data
- BOOL preprocessor // Flag to indicate whether this is a preprocessor or postprocessor
- )
- {
- int i, length=rows*cols;
- float gain = getFloatParameter(instance, 2, 1);
- float offset = getFloatParameter(instance, 3, 1);
-
- for (i=0; i<length; i++)
- output[i] = gain*(input[i] + offset);
- return TRUE;
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- __declspec(dllexport) DLLData *allocPrePost(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int *rows, // Number of rows of output data, can be changed to reflect a diffenent number for the input data
- int *cols, // Number of cols of output data, can be changed to reflect a diffenent number for the input data
- BOOL preprocessor // Flag to indicate whether this is a preprocessor or postprocessor
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- setParameterName(instance, 2, 1, "Gain", FALSE);
- setFloatParameter(instance, 2, 1, 1.0f, FALSE);
- setParameterName(instance, 3, 1, "Offset", FALSE);
- setFloatParameter(instance, 3, 1, 0.0f, FALSE);
- return instance;
- }
-
- __declspec(dllexport) void freePrePost(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-